import { BaseQuery } from "@/types/common/response";

/**
 * 考勤状态枚举
 */
export enum AttendanceStatus {
  /** 正常 */
  NORMAL = "0",
  /** 迟到 */
  LATE = "1",
  /** 早退 */
  EARLY_LEAVE = "2",
  /** 旷工 */
  ABSENT = "3",
  /** 请假 */
  LEAVE = "4",
  /** 外勤 */
  OUTSIDE = "5"
}

/**
 * 考勤状态标签映射
 */
export const STATUS_LABEL_MAP: Record<AttendanceStatus, string> = {
  [AttendanceStatus.NORMAL]: "正常",
  [AttendanceStatus.LATE]: "迟到",
  [AttendanceStatus.EARLY_LEAVE]: "早退",
  [AttendanceStatus.ABSENT]: "旷工",
  [AttendanceStatus.LEAVE]: "请假",
  [AttendanceStatus.OUTSIDE]: "外勤"
};

/**
 * 考勤状态类型映射
 */
export const STATUS_TYPE_MAP: Record<AttendanceStatus, string> = {
  [AttendanceStatus.NORMAL]: "success",
  [AttendanceStatus.LATE]: "warning",
  [AttendanceStatus.EARLY_LEAVE]: "warning",
  [AttendanceStatus.ABSENT]: "danger",
  [AttendanceStatus.LEAVE]: "info",
  [AttendanceStatus.OUTSIDE]: "info"
};

/**
 * 考勤状态选项
 */
export const STATUS_OPTIONS = Object.entries(STATUS_LABEL_MAP).map(([value, label]) => ({
  value: value as AttendanceStatus,
  label
}));

/**
 * 考勤记录查询参数
 */
export interface AttendanceRecordQuery extends BaseQuery {
  /** 考勤记录ID */
  recordId?: number;
  /** 员工ID */
  employeeId?: number;
  /** 员工姓名 */
  employeeName?: string;
  /** 考勤日期范围 - 开始 */
  attendanceDateStart?: string;
  /** 考勤日期范围 - 结束 */
  attendanceDateEnd?: string;
  /** 考勤状态 */
  status?: AttendanceStatus;
}

/**
 * 考勤记录视图对象
 */
export interface AttendanceRecordVO {
  /** 考勤记录ID */
  recordId?: number;
  /** 员工ID */
  employeeId: number;
  /** 员工姓名 */
  employeeName?: string;
  /** 考勤日期 */
  attendanceDate: string;
  /** 签到时间 */
  clockInTime?: string;
  /** 签到地址 */
  clockInAddress?: string;
  /** 签退时间 */
  clockOutTime?: string;
  /** 签退地址 */
  clockOutAddress?: string;
  /** 考勤规则ID */
  ruleId?: number;
  /** 考勤规则名称 */
  ruleName?: string;
  /** 考勤状态 */
  status: AttendanceStatus;
  /** 备注 */
  remark?: string;
  /** 创建时间 */
  createTime?: string;
  /** 更新时间 */
  updateTime?: string;
}

/**
 * 考勤记录表单对象
 */
export interface AttendanceRecordForm {
  /** 考勤记录ID */
  recordId?: number;
  /** 员工ID */
  employeeId: number;
  /** 员工姓名 */
  employeeName: string;
  /** 考勤日期 */
  attendanceDate: string;
  /** 签到时间 */
  clockInTime?: string;
  /** 签到地址 */
  clockInAddress?: string;
  /** 签退时间 */
  clockOutTime?: string;
  /** 签退地址 */
  clockOutAddress?: string;
  /** 考勤规则ID */
  ruleId: number;
  /** 考勤状态 */
  status: AttendanceStatus;
  /** 备注 */
  remark?: string;
}
